<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>
			div{
				width:100px;
				height:100px;
				background: red;
				position:absolute;
			}
		</style>
		<script src="jquery-1.7.2.min.js"></script>
		<script>
			$(function(){
				$('div').mousedown(function(ev){
					var disX = ev.offsetX;
					var disY = ev.offsetY;
					$(document).on('mousemove.drag',function(ev){
						var left = ev.clientX - disX;
						var top = ev.clientY - disY;
						$('div').css({top:top,left:left});
					})
					$(document).on('mouseup.drag',function(ev){
						$(document).off('.drag');
						
					})
					//return false 既可以阻止默认事件，又可以阻止事件流
					return false;
				})
			})
		</script>
	</head>
	<body>
		<div>
		</div>
	</body>
</html>
